<%@page import="java.sql.*"%>
<%
String state=request.getParameter("state");
String name=request.getParameter("name");
 String buffer="<select name=\""+name+"\" class=\"validate['required'] text-input-add\"><option value='-1'>Select</option>";
 try{
 Class.forName("com.mysql.jdbc.Driver").newInstance();
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/recruitment_portal","root","root");
 Statement stmt = con.createStatement();
 ResultSet rs = stmt.executeQuery("Select * from dist where State='"+state+"' order by district");
   while(rs.next()){
   buffer=buffer+"<option value='"+rs.getString(1)+"'>"+rs.getString(1)+"</option>";
   }
 buffer=buffer+"</select>";
 System.out.println(buffer);
 response.getWriter().println(buffer);
 }
 catch(Exception e){
     System.out.println(e);
 }

 %>